package com.mrd;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

import org.springframework.beans.factory.config.PropertyPlaceholderConfigurer;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.context.web.SpringBootServletInitializer;
import org.springframework.boot.web.servlet.ServletComponentScan;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.Resource;
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;

/**
 * Created by winaya on 2016/8/8.
 */


import com.mrd.spring.repository.impl.BaseRepositoryImpl;

/**
 * 项目启动程序 Created by winaya on 2016/5/13.
 */
@SpringBootApplication
@Configuration
@EnableAutoConfiguration
@EnableJpaRepositories(repositoryBaseClass = BaseRepositoryImpl.class)
@ComponentScan
@ServletComponentScan("com.mrd")
// public class StartApplication extends SpringBootServletInitializer {
public class StartApplication extends SpringBootServletInitializer {
  private static ApplicationContext ctx;

  public static void main(String[] args) {
    SpringApplication springApplication = new SpringApplication(StartApplication.class);
    ctx = springApplication.run(args);
    System.err.println("使用配置文件：" + Arrays.toString(ctx.getEnvironment().getActiveProfiles()));
    /*
     * String payid= "CZ40220170606175442648"; PaymentABCBiz1 pab1 =
     * SpringUtils.getBean(PaymentABCBiz1.class); pab1.queryABCPayStatus(payid);
     * System.out.println("执行完毕!");
     */
  }

  @Override
  protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
    return application.sources(StartApplication.class);
  }
  // 添加下面这段代码会造成文件名乱码
  // @Bean
  // public CharacterEncodingFilter initializeCharacterEncodingFilter() {
  // CharacterEncodingFilter filter = new CharacterEncodingFilter();
  // filter.setEncoding("UTF-8");
  // filter.setForceEncoding(true);
  // return filter;
  // }

}
